<?php /*
	
*/ ?>
<?php include("inc/head.inc.php") ?>
<?php
if(!isset($_SESSION['memberid'])) {
	header("location:customerlogin.php?cond=1");
}
?>
<body>
  
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
    <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td valign="top" class="leftmenuback"><?php include(INC."left.inc.php") ?></td>
        <td valign="top">
		<div class="pageheader">Order History</div>
		<form name="acco" action="tracking.php" method="post"><div class="sortoptions">Search By Order Id#:  
			<?php
			$searh=$_REQUEST['search'];
			?>
			<input name="search" type="text" class="feature_headingbg" value="<?php echo $searh;?>" />
			<input name="Submit" type="submit" class="feature_headingbg" value="Go" />
			<?php 
			if(isset($searh) && ($searh!="")) {
				echo "Search By \"$searh\"";
			}
			?>
		</div></form>
		  <br />
		  <?php 
if(isset($_REQUEST['search']) && ($_REQUEST['search'])!="")	{

			if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="") {
				$memid=$_SESSION['memberid'];
			}
			$sql="SELECT * FROM `tblorders` WHERE `intid` = ".mysql_real_escape_string($_REQUEST['search'])." AND `intcustomerid`=$memid";
			$result=$n02586916_db->select($sql);
			if(count($result)>0)
			{
				for($i=0;$i<count($result);$i++)
				{
				$id=$result[$i]['intid'];
				?>
				<div class="sortoptions">
		  <table width="100%" border="0" cellpadding="0" cellspacing="2" class="proborder">
            <tr>
              <td width="27%" class="fntstyle"><strong>Order No:</strong></td>
              <td width="50%" class="font"><?php echo $result[$i]['intid'];?></td>
              <td width="21%" align="center" class="fntstyle"><a href="acchistory.php?orderid=<?php echo $id;?>" class="aa">Detail</a></td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Order Date:</strong></td>
              <td colspan="2" class="font"><?php echo printdate($result[$i]['dtfinished']);?></td>
            </tr>
            <tr>
              <td valign="top" class="fntstyle"><strong>Shipped To:</strong></td>
              <td colspan="2" class="font"><?php echo 
			   stripslashes($result[$i]['vardeliverystreetaddress'])."<br />".
			   stripslashes($result[$i]['vardeliverycity'])."<br />".
			   stripslashes($result[$i]['vardeliverypostcode'])."<br />".
			   stripslashes($result[$i]['vardeliverystate'])."<br />".
			   stripslashes($result[$i]['vardeliverycountry']); ?></td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Products:</strong></td>
              <td colspan="2" class="font">
			  <?php 
		  $sql1="select * from tblorderproducts where intorderid=$id";
		  $res1=$n02586916_db->select($sql1);
		  if($res1) {
			  	for ($b=0;$b<count($res1);$b++) {
			  	$sql9="select * from tblproddesc where intid=".$res1[$b]['intproductid'];
				$resimg=$n02586916_db->select($sql9);
				echo stripslashes($resimg[0]['varprodname'])." (Code: ".$res1[$b]['intproductid'].")<br />";
				}
		   }?>
			  </td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Order Cost:</strong></td>
              <td colspan="2" class="font">&pound;<?php echo $result[$i]['totalvalue'];?></td> 
            </tr>
            <tr>
              <td align="left" valign="top" class="fntstyle"><strong>Order Status:</strong></td>
              <td colspan="2" valign="top" class="font"><?php
			  $staid=$result[$i]['intcurrentorderstatus'];
			  $sql2 = "SELECT *	FROM `tblorderstatus` WHERE intid=$staid"; 
			  $res2 = $n02586916_db->select($sql2);
			  echo stripslashes($res2[0][1]);	
			  ?></td>
            </tr></table></div><br />
		<?php }
			}
		?>
 
<?php } else {
			  if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="") {
					$memid=$_SESSION['memberid'];
				}
		 /**************************************
				PAGING CODE START
		**************************************/
		$rowperpage=3;
		$tablename="tblorders";
		$per_page_keywords= "intcustomerid='$memid'";
		$per_page_sorts="";
		include("system/paging.inc.php");

		/**************************************
				PAGING CODE ENDING
		**************************************/
			
			$sql="select * from tblorders where ".$per_page_keywords." LIMIT ".($page_no*$row_per_page).",".$row_per_page;
			$result=$n02586916_db->select($sql);
			if(count($result)>0)
			{
				for($i=0;$i<count($result);$i++)
				{
				$id=$result[$i]['intid'];		
		?>
		<div class="sortoptions">
		  <table width="100%" border="0" cellpadding="0" cellspacing="2" class="proborder">
            <tr>
              <td width="27%" class="fntstyle"><strong>Order No:</strong></td>
              <td width="50%" class="font"><?php echo $result[$i]['intid'];?></td>
              <td width="21%" align="center" class="fntstyle"><a href="acchistory.php?orderid=<?php echo $id;?>" class="aa">Detail</a></td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Order Date:</strong></td>
              <td colspan="2" class="font"><?php echo printdate($result[$i]['dtfinished']);?></td>
            </tr>
            <tr>
              <td valign="top" class="fntstyle"><strong>Shipped To:</strong></td>
              <td colspan="2" class="font"><?php echo 
			   stripslashes($result[$i]['vardeliverystreetaddress'])."<br />".
			   stripslashes($result[$i]['vardeliverycity'])."<br />".
			   stripslashes($result[$i]['vardeliverypostcode'])."<br />".
			   stripslashes($result[$i]['vardeliverystate'])."<br />".
			   stripslashes($result[$i]['vardeliverycountry']); ?></td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Products:</strong></td>
              <td colspan="2" class="font">
			  <?php 
		  $sql1="select * from tblorderproducts where intorderid=$id";
		  $res1=$n02586916_db->select($sql1);
		  if($res1) {
			  	for ($b=0;$b<count($res1);$b++) {
			  	$sql9="select * from tblproddesc where intid=".$res1[$b]['intproductid'];
				$resimg=$n02586916_db->select($sql9);
				echo stripslashes($resimg[0]['varprodname'])." (Code: ".$res1[$b]['intproductid'].")<br />";
				}
		   }?>
			  </td>
            </tr>
            <tr>
              <td class="fntstyle"><strong>Order Cost:</strong></td>
              <td colspan="2" class="font">&pound;<?php echo $result[$i]['totalvalue'];?></td> 
            </tr>
            <tr>
              <td align="left" valign="top" class="fntstyle"><strong>Order Status:</strong></td>
              <td colspan="2" valign="top" class="font"><?php
			  $staid=$result[$i]['intcurrentorderstatus'];
			  $sql2 = "SELECT *	FROM `tblorderstatus` WHERE intid=$staid"; 
			  $res2 = $n02586916_db->select($sql2);
			  echo stripslashes($res2[0][1]);	
			  ?></td>
            </tr></table></div><br />
			<?php 
			}
		  	echo "<div class=\"font\"><br />";
			pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page);
			echo "</div>";
		 }
	}
 ?>
		  </td>
        </tr> 
      </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>
